# -*- coding: utf-8 -*-
from machine import UART
import utime as time

huart2 = UART(UART.UART2, 115200, 8, 0, 1, 0)

def UART2_Read_Callback(para):    
    if para[0] == 0:
        if para[1]==2:
            data=huart2.read(para[2])
            str=decode()
            print(str)
            huart2.write(data)

def UART2_Init():
    huart2.set_callback(UART2_Read_Callback)
def main():
    time.sleep(1)
    print('system info:{}'.format(os.uname()))
    UART2_Init()
    while True:
        date=time.localtime()
        print("{0}-{1}-{2} {3}:{4}:{5}".format(date[0],date[1],date[2],date[3],date[4],date[5]))
        time.sleep(1)
        pass

if __name__ == '__main__':
    main()


